OpenBuildings GenerativeComponents Help

Variables

A variable is a storage area that can hold a value, and is labeled with a name. The stored value can be retrieved simply by using the variable's name.

You can store as many values as you want into a variable, but only one value at a time. Each new value replaces the previous value.

Declaring Variables

Before you can use a variable for the first time, you must declare it. This means telling GCScript the name of the new variable, and the type of values you expect to store into it.

General Form

type name

Examples

int poleCount
string levelName
bool isImageInverted

As a convenience, you can define multiple variables of the same type with one statement.

Example

double minorRadius, majorRadius, angle, chordLength

Each variable may contain only a value of the type that you specified in its declaration. For example, a variable of type int can contain any of the values 5, 1094, or -13, but not the string value 'one dozen'.

Sometimes, you don't know precisely what types of values will be stored into a variable, or you want to be able to store different types at different times. In that case, you can use the generic type, object. An object-type variable can hold any value of any type (because every value is an object, in addition to whatever other type it is).

Example

object resultOfOperation  // Could be a number or
perhaps an error message.